package com.framework.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.OrLessionDao;
import com.framework.entity.or.OrBanner;
import com.framework.entity.or.OrLession;
import com.framework.entity.sys.SysAgent;
import com.framework.page.PageUtils;
import com.framework.page.Query;
import com.framework.service.AgentService;
import com.framework.service.BannerService;
import com.framework.service.OrLessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 课程业务实现
 * @author wq
 */
@Transactional(rollbackFor = Exception.class)
@Service("orLessionServiceImpl")
public class OrLessionServiceImpl extends ServiceImpl<OrLessionDao,OrLession> implements OrLessionService {
    @Autowired
    private AgentService agentService;

    @Autowired
    private BannerService bannerService;
    @Override
    public OrBanner getLessonHeader(String token) {
        SysAgent agent = agentService.queryAgentByToken(token);

        OrBanner banner = bannerService.selectOne(new EntityWrapper<OrBanner>().eq("dept_id", agent.getDeptId())
                .eq("type", 4).eq("state", 1)
        );
        return banner;
    }

    @Override
    public List<OrBanner> queryLessonList(String token, Integer type) {
        SysAgent agent = agentService.queryAgentByToken(token);
        List<OrBanner> list = bannerService.selectList(new EntityWrapper<OrBanner>().eq("dept_id", agent.getDeptId())
                .eq("type", type).eq("state",1)
        );
        return list;
    }

}
